# 指定基础镜像与时区
FROM centos:7
ENV TZ=Asia/Shanghai

# 安装依赖，创建nginx用户
RUN yum -y install epel* gcc make pcre-devel openssl-devel &&\
	useradd -s /sbin/nologin -M nginx

# 复制并解压nginx，然后切换至nginx目录下
ADD nginx-1.19.0.tar.gz /usr/local/src/
WORKDIR /usr/local/src/nginx-1.19.0/

# 编译、安装nginx
RUN ./configure --prefix=/usr/local/nginx/ --user=nginx --group=nginx --with-stream \
	--with-http_stub_status_module --with-http_ssl_module && make && make install &&\
	rm -rf /usr/local/src/nginx-1.19.0*
	
# 设置开放端口，启动nginx
WORKDIR /
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nginx/sbin
EXPOSE 80 443
CMD ["nginx","-g","daemon off;"]